<script lang="ts" setup name="HomeSpecial">
import HomePanel from './HomePanel.vue'
import useStore from '@/store'
// 数据懒加载函数
import { useLazyData } from '@/utils/hooks'
const { home } = useStore()
const target = useLazyData(home.getSpecialList)
</script>
<template>
    <div ref="target">
        <HomePanel title="最新专题" sub-title="">
            <template v-slot:right>
                <XtxMore path="" />
            </template>
            <div class="special-list" ref="homeSpecial" v-if="home.specialList.length > 0">
                <div class="special-item" v-for="item in home.specialList" :key="item.id">
                    <RouterLink to="/">
                        <img v-lazy="item.cover" alt="" />
                        <div class="meta">
                            <p class="title">
                                <span class="top ellipsis">{{ item.title }}</span>
                                <span class="sub ellipsis">{{ item.summary }}</span>
                            </p>
                            <span class="price">&yen;{{ item.lowestPrice }}起</span>
                        </div>
                    </RouterLink>
                    <div class="foot">
                        <span class="like"><i class="iconfont icon-hart1"></i>{{ item.collectNum }}</span>
                        <span class="view"><i class="iconfont icon-see"></i>{{ item.viewNum }}</span>
                        <span class="reply"><i class="iconfont icon-message"></i>{{ item.replyNum }}</span>
                    </div>
                </div>
            </div>
            <!-- 骨架屏 -->
            <div class="home-skeleton" v-else>
                <div class="item" v-for="i in 3" :key="i" :style="{ backgroundColor: '#f0f9f4' }">
                    <XtxSkeleton bg="#e4e4e4" :width="404" :height="288" animated fade />
                    <div class="box">
                        <XtxSkeleton bg="#e4e4e4" :width="57" :height="24" animated fade />
                        <XtxSkeleton bg="#e4e4e4" :width="57" :height="24" animated fade />
                        <XtxSkeleton bg="#e4e4e4" :width="57" :height="24" animated fade />
                    </div>
                </div>
            </div>
        </HomePanel>
    </div>
</template>

<style scoped lang="less">
.home-skeleton {
    width: 1240px;
    height: 360px;
    display: flex;
    justify-content: space-between;

    .box {
        padding: 0 30px;
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        align-content: center;
    }

    .item {
        // width: 306px;

        .xtx-skeleton~.xtx-skeleton {
            display: block;
            margin-left: 30px;
        }
    }
}

.home-panel {
    background: #f5f5f5;
}

.special-list {
    height: 380px;
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;

    .special-item {
        width: 404px;
        background: #fff;
        .hoverShadow();

        a {
            display: block;
            width: 100%;
            height: 288px;
            position: relative;

            img {
                width: 100%;
                height: 100%;
            }

            .meta {
                background-image: linear-gradient(to top,
                        rgba(0, 0, 0, 0.8),
                        transparent 50%);
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 288px;

                .title {
                    position: absolute;
                    bottom: 0px;
                    left: 0;
                    padding-left: 16px;
                    width: 70%;
                    height: 70px;

                    .top {
                        color: #fff;
                        font-size: 22px;
                        display: block;
                    }

                    .sub {
                        display: block;
                        font-size: 19px;
                        color: #999;
                    }
                }

                .price {
                    position: absolute;
                    bottom: 25px;
                    right: 16px;
                    line-height: 1;
                    padding: 4px 8px 4px 7px;
                    color: @priceColor;
                    font-size: 17px;
                    background-color: #fff;
                    border-radius: 2px;
                }
            }
        }

        .foot {
            height: 72px;
            line-height: 72px;
            padding: 0 20px;
            font-size: 16px;

            i {
                display: inline-block;
                width: 15px;
                height: 14px;
                margin-right: 5px;
                color: #999;
            }

            .like,
            .view {
                float: left;
                margin-right: 25px;
                vertical-align: middle;
            }

            .reply {
                float: right;
                vertical-align: middle;
            }
        }
    }
}
</style>